﻿
Imports osi.root.connector
Imports osi.root.delegates
Imports osi.root.formation
Imports osi.root.procedure
Imports osi.service.argument
Imports osi.service.configuration
Imports osi.service.selector

Partial Public Class device_constructor
    Private Sub New()
    End Sub

    Public Shared Function register(Of T)(ByVal allocator As allocator(Of T, var)) As Boolean
        Return device_constructor(Of T).register(allocator)
    End Function

    Public Shared Function register(Of T)(ByVal type As String,
                                          ByVal allocator As allocator(Of T, var)) As Boolean
        Return device_constructor(Of T).register(type, allocator)
    End Function

    Public Shared Function resolve_only(Of T)(ByVal type As String,
                                              ByVal v As var,
                                              ByVal o As pointer(Of T)) As event_comb
        Return device_constructor(Of T).resolve_only(type, v, o)
    End Function

    Public Shared Function resolve_only(Of T)(ByVal v As var, ByVal o As pointer(Of T)) As event_comb
        Return device_constructor(Of T).resolve_only(v, o)
    End Function

    Public Shared Function resolve(Of T)(ByVal type As String,
                                         ByVal v As var,
                                         ByVal o As pointer(Of T),
                                         Optional ByVal create_singleton_device_pool As  _
                                             binder(Of _do_val_ref(Of T, 
                                                                      singleton_device_pool(Of T),
                                                                      Boolean), 
                                                       device_constructor(Of T)) = Nothing) As event_comb
        Return device_constructor(Of T).resolve(type, v, o, create_singleton_device_pool)
    End Function

    Public Shared Function resolve(Of T)(ByVal v As var,
                                         ByVal o As pointer(Of T),
                                         Optional ByVal create_singleton_device_pool As  _
                                             binder(Of _do_val_ref(Of T, 
                                                                      singleton_device_pool(Of T),
                                                                      Boolean), 
                                                       device_constructor(Of T)) = Nothing) As event_comb
        Return device_constructor(Of T).resolve(v, o, create_singleton_device_pool)
    End Function

    Public Shared Function resolve(Of T)(ByVal type As String,
                                         ByVal v As section,
                                         ByVal o As pointer(Of T),
                                         Optional ByVal create_singleton_device_pool As  _
                                             binder(Of _do_val_ref(Of T, 
                                                                      singleton_device_pool(Of T),
                                                                      Boolean), 
                                                       device_constructor(Of T)) = Nothing) As event_comb
        Return device_constructor(Of T).resolve(type, v, o, create_singleton_device_pool)
    End Function

    Public Shared Function resolve(Of T)(ByVal v As section,
                                         ByVal o As pointer(Of T),
                                         Optional ByVal create_singleton_device_pool As  _
                                             binder(Of _do_val_ref(Of T, 
                                                                      singleton_device_pool(Of T),
                                                                      Boolean), 
                                                       device_constructor(Of T)) = Nothing) As event_comb
        Return device_constructor(Of T).resolve(v, o, create_singleton_device_pool)
    End Function

    Public Shared Sub set_create_singleton_device_pool_binder(Of T) _
                                                             (ByVal x As _do_val_ref(Of T, 
                                                                                        singleton_device_pool(Of T),
                                                                                        Boolean))
        device_constructor(Of T).set_create_singleton_device_pool_binder(x)
    End Sub

    Public Shared Sub set_create_singleton_device_pool_binder(Of T) _
                                                             (ByVal x As Func(Of T, singleton_device_pool(Of T)))
        device_constructor(Of T).set_create_singleton_device_pool_binder(x)
    End Sub

    Public Shared Sub clear(Of T)()
        device_constructor(Of T).clear()
    End Sub
End Class
